//
//  CityViewController.m
//  09-UI
//
//  Created by Snow on 16/7/26.
//  Copyright © 2016年 Snow. All rights reserved.
//

#import "CityViewController.h"
#import "AreaViewController.h"
#define kReuse @"reuse"

@interface CityViewController ()
@property (nonatomic, strong) NSMutableArray *arrayCity;
@property (nonatomic, strong) NSMutableArray *arrOfArea;
@end

@implementation CityViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:kReuse];
    self.arrayCity = [NSMutableArray array];
    for (NSDictionary *dic in self.arrOfCity) {
        [self.arrayCity addObject:[dic objectForKey:@"cityName"]];
        self.arrOfArea = [dic objectForKey:@"arrayOfArea"];
    }
    
    NSLog(@"%@", self.arrOfCity);
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.arrayCity.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kReuse];
    cell.textLabel.text = [self.arrayCity objectAtIndex:indexPath.row];
    
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    AreaViewController *area = [[AreaViewController alloc] init];
    [self.navigationController pushViewController:area animated:YES];
    area.arrayArea = self.arrOfArea;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
